package com.qc.toutiao.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.qc.toutiao.pojo.Category;
import com.qc.toutiao.services.CategoryService;
import com.qc.toutiao.services.impl.CategoryServiceImpl;

public class CategoryServlet extends HttpServlet {

	private static final long serialVersionUID = 2656357078280509778L;
	private CategoryService categoryService = new CategoryServiceImpl();

	public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {

		this.doPost(request, response);

	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {

		String action = request.getParameter("action");
		if(action == null || "getCategoryAll".equals(action)){
			getCategoryAll(request,response);
		}
	}

	private void getCategoryAll(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
	
		request.setAttribute("categoryList", categoryService.findCategoryAll());
		request.getRequestDispatcher("jsp/profile_issue.jsp").forward(request, response);
	}

}
